#ifndef STM32F1_RTC_H_
#define STM32F1_RTC_H_

#include "iodef.h"

typedef struct {
        __IO uint16_t CRH;
        uint16_t  RESERVED0;
        __IO uint16_t CRL;
        uint16_t  RESERVED1;
        __IO uint16_t PRLH;
        uint16_t  RESERVED2;
        __IO uint16_t PRLL;
        uint16_t  RESERVED3;
        __IO uint16_t DIVH;
        uint16_t  RESERVED4;
        __IO uint16_t DIVL;
        uint16_t  RESERVED5;
        __IO uint16_t CNTH;
        uint16_t  RESERVED6;
        __IO uint16_t CNTL;
        uint16_t  RESERVED7;
        __IO uint16_t ALRH;
        uint16_t  RESERVED8;
        __IO uint16_t ALRL;
        uint16_t  RESERVED9;
}rtc_reg_t;

#define RTC_CRH_SECIE           _BIT(0)
#define RTC_CRH_ALRIE           _BIT(1)
#define RTC_CRH_OWIE            _BIT(2)

#define RTC_CRL_SECF            _BIT(0)
#define RTC_CRL_ALRF            _BIT(1)
#define RTC_CRL_OWF             _BIT(2)
#define RTC_CRL_RSF             _BIT(3)         /* Registers synchronized flag */
#define RTC_CRL_CNF             _BIT(4)         /* Enter configuration mode */
#define RTC_CRL_RTOFF           _BIT(5)         /*  Last write operation on RTC registers terminated */

#define RTC     ((rtc_reg_t *)RTC_BASE)

#endif /* STM32F1_RTC_H_ */
